package util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;

import android.text.format.DateFormat;

/** Simpel dataklasse til at gemme XML-vÃ¦rdier i */
public class Item {

	public String placering;
	public String hold;
	public String antal_kampe;
	public String vundne;
	public String uafgjorte;
	public String tabte;
	public String maal;
	public String maal_imod;
	public String point;
	private String maal_dif;
	public String tal;
	public String vat;
	public String navn;
	public String sponsor;
	public String image;
	public String nummer;
	public String Troejenummer;
	public String position;
	public String title;
	public String description;
	public String link;
	public String pubDate;
	public String category;
	public String content;
	public String dag;
	public String tidspunkt;
	public String hjemmehold;
	public String udehold;
	public String resultat;
	
	public ArrayList<Item> AarupKamp = new ArrayList<Item>();
	public ArrayList<Item> kamp;
	public String tid;
	public static String nextMatch;
	

	

public String getMaal(){
	Item item = this;
	maal_dif = maal +"-"+ maal_imod;
	tal =   item.maal_dif;
	return tal;
}
public String getName() {

	return hold;
}
public String getPlacering() {
	return placering;
}
public String getVat() {
	vat = " " + vundne + "-" + uafgjorte + "-" + tabte;
	return vat;
}
public String getKampe() {
	return antal_kampe;
}
public String getPoint() {
	return point;
}
public String getNavn() {
	return navn;
}
public String getSponsor() {
	return sponsor;
}
public String getImage() {
	return image;
}
public String getTroejenummer() {
	return Troejenummer;
}
public String getPosition() {
	return position;
}
public String getTitle() {
	return title;
}
public String getDescription() {
//	String short_description = new StringBuilder ("s").append(description).substring(100, 220);
	return description;
}
public String getCategory(){
	return category;
}
public String getContent(){
	return content;
}
public String getDag() {
	// TODO Auto-generated method stub
	return dag;
}
public String getTidspunkt() {
	// TODO Auto-generated method stub
	return tidspunkt;
}
public String getHjemmehold() {
	// TODO Auto-generated method stub
	return hjemmehold;
}
public String getUdehold() {
	// TODO Auto-generated method stub
	return udehold;
}
public String getTid() {
	// TODO Auto-generated method stub
	return tid;
}
public String getResultat() {
	// TODO Auto-generated method stub
	return resultat; 
}
public String getNextMatch(){
	return nextMatch;
}


public ArrayList<Item> Iterate(ArrayList<Item> kamp)  {
	Date nextGameDate = new Date();
	Date dato = new Date();
	Boolean next = true;
	
	for (int i = 0; i < kamp.size(); i++) {
	    if(kamp.get(i).getHjemmehold().equals("Aarup")||kamp.get(i).getUdehold().equals("Aarup")){
	        //do something
	    	
	    	Item item = kamp.get(i);
	    	AarupKamp.add(item);
	    	
	    	try {
			SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yy");
			nextGameDate = sdf.parse(kamp.get(i).getTidspunkt());
			
	    	
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	    	 if(kamp.get(i).getHjemmehold().equals("Aarup") && dato.before(nextGameDate) && next==true ){
	    		 next = false;
	    		 int iGameday = i;
	    		nextMatch = kamp.get(iGameday).getUdehold() + "\n" + kamp.get(iGameday).getDag()+" " + kamp.get(iGameday).getTidspunkt()+" kl:  " + kamp.get(iGameday).getTid();
//				System.out.println("fra nextgamedate" + kamp.get(i).getHjemmehold().equals("Aarup") + " "+ dato + " er før " + nextGameDate + " ? " + dato.after(nextGameDate));
	 	    		}
	 			}
	    	
		}
return AarupKamp;
}




}

